//
//  CSGXInventoryManageFooter.m
//  CarSalesMS_GCX
//
//  Created by Ssky on 2016/12/19.
//  Copyright © 2016年 Tony. All rights reserved.
//

#import "CSGXInventoryManageFooter.h"
#import "RMCheckButton.h"

@interface CSGXInventoryManageFooter ()

@property (nonatomic, weak) UILabel *lblCountMoney;


@end

@implementation CSGXInventoryManageFooter

#pragma mark - Actions
- (void)btnCheckValueChanged:(RMCheckButton *)btnCheck event:(UIControlEvents *)event {
    self.isChecked = (btnCheck.ischeck == selectCheck) ? YES : NO;
    [self sendActionsForControlEvents:UIControlEventValueChanged];
}


#pragma mark - methods
- (void)distribute {
    self.lblCountMoney.text = [NSString stringWithFormat:@"共计%lu条,金额:￥%.2f", (unsigned long)self.inventoryManagerFooterList.count, self.totalInventoryMoney];
}


#pragma mark - delegates




#pragma mark - setupUI
- (void)setupUI {
    //
    UILabel *lblCountMoney = [UILabel gx_labelWithText:@"共计1条,金额:￥17250.00" fontSize:13 color:[UIColor whiteColor]];
    [self addSubview:lblCountMoney];
    self.lblCountMoney = lblCountMoney;
    
    [lblCountMoney mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.leading.bottom.equalTo(self).mas_offset(0);
    }];

    
    //vCheck
    UIView *vCheck = [[UIView alloc] init];
    [self addSubview:vCheck];
    
    [vCheck mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.trailing.equalTo(self).mas_offset(0);
        make.width.equalTo(self).multipliedBy(0.5);
    }];
    
    UILabel *lblContain = [UILabel gx_labelWithText:@"包含0库存日报" fontSize:13 color:[UIColor whiteColor]];
    [vCheck addSubview:lblContain];
    
    [lblContain mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.trailing.equalTo(vCheck).mas_offset(0);
        make.centerY.equalTo(self);
    }];

    //添加单选框
    RMCheckButton *btnCheck = [[RMCheckButton alloc] init];
    [vCheck addSubview:btnCheck];

    [btnCheck mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.equalTo(lblContain.mas_leading).mas_offset(-5);
        make.centerY.equalTo(lblContain).mas_offset(0);
        make.size.mas_offset(CGSizeMake(25, 25));
    }];
    
    [btnCheck addTarget:self action:@selector(btnCheckValueChanged:event:) forControlEvents:UIControlEventValueChanged];

    
}




#pragma mark - setter & getter

- (void)setInventoryManagerFooterList:(NSArray<TInventoryModel *> *)inventoryManagerFooterList {
    _inventoryManagerFooterList = inventoryManagerFooterList;
    
    [self distribute];
}

- (void)setTotalInventoryMoney:(CGFloat)totalInventoryMoney {
    _totalInventoryMoney = totalInventoryMoney;
    [self distribute];
}





@end
